<?php
Prado::using('Application.common.common');
class OrderHistory extends TPage
{
	public function onLoad($param)
	{
		parent::onLoad($param);
		$this->Master->pageHead->Title = $this->Application->Parameters["WEBSITE_TITLE"] . " | Order History";
		
		if (!$this->IsPostBack)
		{			
			$this->populateData();
		}
	}	
	
	public function populateData()
	{
		$criteria = new TActiveRecordCriteria;
		$criteria->Condition = "order_id > 0 and user_id = :id";
		$criteria->Parameters[":id"] = $this->Application->User->ID;
		$criteria->OrdersBy["c_date"] = "desc";
		$this->rptOrder->DataSource = OrderRecord::finder()->findAll($criteria);
		$this->rptOrder->DataBind();
		
		if (count(OrderRecord::finder()->findAll($criteria)) == 0)
			$this->lblNoOrder->Visible = true;
	}
		
	protected function btnContinue_Clicked($sender, $param)
	{
		$this->Response->redirect($this->Service->ConstructUrl("Index"));
	}
	
	protected function btnCancel_Clicked($sender, $param)
	{
		$this->Response->redirect($this->Service->ConstructUrl("account.Profile"));
	}
}

?>